import { Component, ChangeDetectionStrategy } from '@angular/core';
import { ModalService } from '@iux/live';

@Component({
  selector: 'lv-size',
  templateUrl: './size.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SizeComponent {
  constructor(private modalService: ModalService) {}

  open(size) {
    this.modalService.create({
      lvModalKey: `my_drawer`,
      lvType: 'drawer',
      lvWidth: size,
      lvOuterClosable: true,
      lvDrawerPosition: 'right',
      hideButton: true,
      lvDrawerPositionOffset: ['0px', '0px', '0px', '0px'],
      lvHeader: 'Modal Title',
      lvContent: `This is ${size} size Drawer!`,
      lvComponentParams: {
        title: 'This is transfer parameter',
      },
      lvAfterOpen: modal => {
        console.log(modal.getContentComponent());
      },
      lvOk: () =>
        new Promise<void>(resolve => {
          setTimeout(() => {
            resolve();
          }, 2000);
        }),
    });
  }
}
